﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.guide.ui {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.geom.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import com.greensock.*;
    import Display.aswingui.*;

    public class GuideDialog extends GenericDialog {

        public static const POS_CENTER:int = 0;
        public static const POS_NW:int = 1;
        public static const POS_NE:int = 2;
        public static const POS_SW:int = 3;
        public static const POS_SE:int = 4;
        public static const POS_ABS:int = 5;

        private var m_asset:MovieClip;
        private var m_buttonName:String;
        private var m_tweenTime:Number = 0.25;
        private var m_position:int = 0;
        private var m_offsetX:Number = 0;
        private var m_offsetY:Number = 0;
        protected var m_avatarOffsetX:Number = 0;
        protected var m_avatarOffsetY:Number = 0;
        protected var m_advisor:DisplayObject;
        protected var m_avatarWindow:JWindow;
        protected var m_assetsLoaded:int = 0;
        protected var m_avatarURL:String;
        protected var m_avatarContentLoader:Loader;
        protected var m_bgContentLoader:Loader;
        protected var m_avatarLocation:String;

        public function GuideDialog(_arg1:String, _arg2:String, _arg3:String, _arg4:Boolean=false, _arg5:int=0, _arg6:Number=0, _arg7:Number=0, _arg8:String="", _arg9:Number=0, _arg10:Number=0, _arg11:String="right"){
            this.m_avatarURL = _arg8;
            this.m_buttonName = _arg3;
            this.m_position = _arg5;
            this.m_offsetX = _arg6;
            this.m_offsetY = _arg7;
            this.m_avatarOffsetX = _arg9;
            this.m_avatarOffsetY = _arg10;
            this.m_avatarLocation = _arg11;
            super(_arg1, "", 0, null, _arg2, "", _arg4);
        }
        override public function isLockable():Boolean{
            return (false);
        }
        public function setTweenTime(_arg1:Number):void{
            this.m_tweenTime = _arg1;
        }
        protected function onStage():void{
            this.addListeners();
        }
        override protected function loadAssets():void{
            var _local1:String = Global.getAssetURL(this.m_avatarURL);
            this.m_avatarContentLoader = LoadingManager.load(_local1, this.onAssetsLoaded);
            var _local2:String = Global.getAssetURL("assets/dialogs/TutorialAssets.swf");
            this.m_bgContentLoader = LoadingManager.load(_local2, this.onAssetsLoaded);
        }
        override protected function onAssetsLoaded(_arg1:Event=null):void{
            this.m_assetsLoaded++;
            if (this.m_assetsLoaded < 2){
                return;
            };
            var _local2:Dictionary = new Dictionary();
            var _local3:Object = this.m_bgContentLoader.content;
            _local2["speechBubble"] = ((this.m_avatarLocation == GuideDialogView.ADVISOR_LOCATION_RIGHT)) ? (new _local3.speechBubbleRight() as DisplayObject) : (new _local3.speechBubbleLeft() as DisplayObject);
            this.m_advisor = this.m_avatarContentLoader.content;
            m_jpanel = new GuideDialogView(_local2, m_message, m_title, m_type, m_callback, this.m_avatarLocation);
            this.finalizeAndShow();
        }
        override protected function finalizeAndShow():void{
            var _local1:Sprite = new Sprite();
            this.addChildAt(_local1, 0);
            this.m_avatarWindow = new JWindow(_local1);
            var _local2:AssetPane = new AssetPane(this.m_advisor);
            this.m_avatarWindow.setContentPane(_local2);
            ASwingHelper.prepare(this.m_avatarWindow);
            this.m_avatarWindow.show();
            this.m_avatarWindow.setX(this.m_avatarOffsetX);
            this.m_avatarWindow.setY(this.m_avatarOffsetY);
            ASwingHelper.prepare(m_jpanel);
            m_jwindow.setContentPane(m_jpanel);
            ASwingHelper.prepare(m_jwindow);
            m_jwindow.setX(136);
            m_jwindow.show();
            setupDialogStatsTracking();
            onDialogInitialized();
        }
        protected function addListeners():void{
        }
        protected function removeListeners():void{
        }
        override protected function hideTween(_arg1:Function):void{
            this.mouseEnabled = false;
            this.mouseChildren = false;
            if (_arg1 != null){
                TweenLite.to(m_content, this.m_tweenTime, {
                    alpha:0,
                    onComplete:_arg1
                });
            } else {
                TweenLite.to(m_content, this.m_tweenTime, {alpha:0});
            };
        }
        override protected function showTween():void{
            this.mouseEnabled = false;
            this.mouseChildren = false;
            var _local1:Number = Math.min(Global.ui.width, Global.stage.stageWidth);
            var _local2:Number = Math.min(Global.ui.height, Global.stage.stageHeight);
            switch (this.m_position){
                case POS_CENTER:
                    this.centerPopup();
                    break;
                case POS_NW:
                    this.x = this.m_offsetX;
                    this.y = this.m_offsetY;
                    break;
                case POS_NE:
                    this.x = ((_local1 - this.width) - this.m_offsetX);
                    this.y = this.m_offsetY;
                    break;
                case POS_SW:
                    this.x = this.m_offsetX;
                    this.y = ((_local2 - this.height) - this.m_offsetY);
                    break;
                case POS_SE:
                    this.x = ((_local1 - this.width) - this.m_offsetX);
                    this.y = ((_local2 - this.height) - this.m_offsetY);
                    break;
                case POS_ABS:
                    this.x = this.m_offsetX;
                    this.y = this.m_offsetY;
                    break;
            };
            var _local3:Point = new Point(m_content.width, m_content.height);
            var _local4:Matrix = new Matrix();
            _local4.scale(1, 1);
            m_content.transform.matrix = _local4;
            TweenLite.from(m_content, this.m_tweenTime, {
                alpha:0,
                onComplete:onShowComplete
            });
        }
        override public function centerPopup():void{
            super.centerPopup();
            this.y = (this.y + 20);
        }
        private function onButtonClick(_arg1:MouseEvent):void{
            close();
        }

    }
}//package Modules.guide.ui 
